function initNavigateHeader(){
    var currentHref = window.location.href;
    var search = window.location.search;
    if(search){
        currentHref = currentHref.split(search)[0];
    }
    var aList = $("nav a");
    for(var i = 0; i < aList.length; i++){
        var  tempHref = $(aList[i]).attr("href").split("?")[0];
        if(tempHref.indexOf(currentHref) > -1 && currentHref.indexOf(".html") > -1){
            $(aList[i]).addClass("current");
        }
        else if(currentHref.indexOf(".html") == -1 && (tempHref == currentHref || (tempHref+"/") == currentHref )) {
            $(aList[i]).addClass("current");
        }
        else{
            $(aList[i]).removeClass("current");
        }
    }
    var liList  = $(".nav li"), widthValue = 0;
    for(var i = 0; i < liList.length; i++){
        widthValue += $(liList[i]).width();
    }
    if(widthValue < 650){
        $("nav.nav").find(".fold-u").css("display", "none");
        $("nav.nav ul").css({"padding-right": "0", "display": "flex", "text-align": "center"})
        $("nav.nav ul li").css({"display": "flex", "flex": "1"})
    }
}
function navSetHeader(){
    $("nav .fold-u").on("click",function(){
        if($(this).hasClass("fold-d")){
            $(this).removeClass("fold-d")
            $(this).prev().css({"height":""});
        }else{
            $(this).addClass("fold-d")
            $(this).prev().css({"height":"auto"});
        }

    });
}
$(document).ready(function(){
    initNavigateHeader();
    navSetHeader();
});